package com.kimehwa.studyboot.zuoalgs;

import java.util.Scanner;

/**
 * @author xiaodongguan
 * @description 在行列都排好序的矩阵中找指定的数
 * @since 2021-07-28 23:16
 */
public class FindNumInMatrix01 {

    public static boolean ifKInMatrix(int[][] matrix, int k) {
        int rows = matrix.length, cols = matrix[0].length;
        int i = 0, j = cols - 1;
        while (i < rows && j >= 0) {
            if (matrix[i][j] == k) {
                return true;
            } else if (matrix[i][j] < k) {
                i++;
            } else {
                j--;
            }
        }
        return false;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                matrix[i][j] = sc.nextInt();
            }
        }
        boolean res = ifKInMatrix(matrix, k);
        if (res) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }

    }
}
